# -*- coding: utf-8 -*-
"""
Created on Wed Aug 14 15:19:54 2013

@author: Jeanhwea
"""

import urllib
import urlparse as prs

class LoadInf:
    def __init__(self, price):
        base = 'http://localhost:8080'
        path = '/gold'
        self.text = ''
        if price:
            self.price = str(price)
        else:
            self.price = ''
        quary = urllib.urlencode( [('action','showByPrice'),('Price',self.price)])
        print quary
        self.url = '?'.join([prs.urljoin(base, path),quary])
        print self.url
        
    def openUrl(self):
        page = urllib.urlopen(self.url)
        self.text = page.read()
        page.close()
        print self.text
        
    def showNum(self):
        pt = 'Total'
        index = self.text.find(pt)
        print index
        return self.text[index+6, index+7]
        
pp = LoadInf(258.17)
pp.openUrl()
#print pp.showNum()